package cn.dida.service.impl;

import cn.dida.dao.PbcDao;
import cn.dida.model.Pbc;
import cn.dida.model.Pageable;
import cn.dida.service.PbcService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
/**
 * <p>箱规管理 业务层接口实现类</p>
 * @author weiwei
 *
 */
@Service
public class PbcServiceImpl implements PbcService {
    @Autowired
    private PbcDao pbcDao;

    @Override
    public Pageable<Pbc> queryPbc(Integer companyId, Integer pcount, Integer state, int page) {
        return pbcDao.query(companyId, pcount, state, page);
    }

    @Override
    public List<Pbc> queryPbc(Integer companyId, Integer state) {
        return pbcDao.query(companyId, state);
    }
    @Transactional
    @Override
    public Boolean insertPbc(Pbc pbc) {
        return pbcDao.insert(pbc) == 1;
    }
    @Transactional
    @Override
    public Boolean updatePbc(Pbc pbc) {
        return pbcDao.update(pbc) == 1;
    }

    @Override
    public Pbc getPbc(Integer companyId, Integer id) {
        return pbcDao.get(companyId, id);
    }

    @Override
    public Pbc getPbcByPcount(Integer companyId, Integer pcount) {
        return pbcDao.getByPcount(companyId, pcount);
    }
    @Transactional
    @Override
    public Boolean deletePbc(Integer companyId, Integer id) {
        return pbcDao.delete(companyId, id) == 1;
    }
}
